/**
 *
 * Copyright by Samuel Castro & Joaquim Fonseca, 2011
 * All Rights Reserved
 *
 * NOTES:
 * Please do not redistribute this plugin without my permission
 * Plugin made for private use only
 *
 */
package com.SyDeck.sdCities;

import com.nijiko.coelho.iConomy.iConomy;
import org.bukkit.Server;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

/**
 *
 * @author Deck
 */
public class Main extends JavaPlugin {

    /**
     * @param args the command line arguments
     */
    private final rpgBlockListener BL = new rpgBlockListener();
    private final Entitydmg Ed = new Entitydmg();
    private final CityPath CP = new CityPath();
    private static PluginListener PluginListener = null;
    private static iConomy iConomy = null;
    private static Server Server = null;

    public static void main(String[] args) {
        //todo
    }

    public void onEnable() {
        PluginDescriptionFile pdfFile = this.getDescription();
        PluginManager pm = getServer().getPluginManager();
        //register commands
        getCommand("city").setExecutor(new decksMethods(this));
        getCommand("cinfo").setExecutor(new decksMethods(this));
        getCommand("cop").setExecutor(new decksMethods(this));
        getCommand("cowner").setExecutor(new decksMethods(this));
        getCommand("ctodo").setExecutor(new decksMethods(this));
        //event register
        pm.registerEvent(Event.Type.BLOCK_PLACE, this.BL, Priority.Low, this);
        pm.registerEvent(Event.Type.BLOCK_BREAK, this.BL, Priority.Low, this);
        //pm.registerEvent(Event.Type.CREATURE_SPAWN, this.E, Priority.Normal, this);
        pm.registerEvent(Event.Type.EXPLOSION_PRIME, this.Ed, Priority.Highest, this);
        pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.Ed, Priority.Highest, this);
        pm.registerEvent(Event.Type.PLAYER_INTERACT, this.CP, Priority.Highest, this);
        //Create path and files
        CityInfo ci = new CityInfo();
        ci.startup();
        //load files
        rpgBlockListener rpgb = new rpgBlockListener();
        rpgb.buildhash();
        CP.LoadPath();
        //iConomy stuff
        Server = getServer();
        PluginListener = new PluginListener();
        getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_ENABLE, PluginListener, Priority.Monitor, this);
    }

    public void onDisable() {
        System.out.println("disabled, goodbye wold");
    }

    public static Server getBukkitServer() {
        return Server;
    }

    public static iConomy getiConomy() {
        return iConomy;
    }

    public static boolean setiConomy(iConomy plugin) {
        if (iConomy == null) {
            iConomy = plugin;
        } else {
            return false;
        }
        return true;
    }
}
